<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
        <style type="text/css">
            .tablegrid tr th.t {text-align: right;padding-right:10px;}
            .tablegrid tr th span.gotop {text-align: right;padding-right:10px;font-weight: normal;color:#06f;float:right;cursor: pointer;}
            #base_link {position:absolute;position:fixed;right:10px;top:40px;background:#F7F0A0;width:150px;height:160px;padding:10px 5px;}
            #base_link a {display:block;height:22px;line-height: 22px;text-indent:10px;}
            #base_link a:hover {color:#f60;}
            .modules {padding:5px 0;}
            .modules li {float:left;width:140px;display:block;height:22px;line-height: 22px;}
            .modules li b{float:left;width:50px;display:block;text-align: right;margin-right:5px;font-weight:normal;}
            .currency li {list-style: none;float:left;width:119px;text-align: left;text-indent:10px;}
            .currency li input{margin:0;width:75px;}
            .tablegrid .currency td.act2 {padding-left:0;}
        </style>
    </head>
    <body>
        <?php include(VIEWPATH . 'common/main_header.php'); ?>
<!--        <span  id="base_link">
            <a href="javascript:;" style="color:#f00;" id="restore"><?= translate('GENERAL_CONFIG_RECOVER') ?></a>
        </span>-->
        <form action="<?= site_url("general/config/edit") ?>" method="POST">
            <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
                <tr align="left" id="basic">
                    <th class="t"><?= $title ?></th>
                    <th></th>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_GAME_NAME') ?>:</td>
                    <td>
                        <input type="text" name="sitename" value="<?= $config['sitename'] ?>" />
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_RESOURCE_URL') ?>:</td>
                    <td>
                        <input type="text" name="res_url" value="<?= $config['res_url'] ?>" style="width:325px" />
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_MAIN_HOST') ?>:</td>
                    <td>
                        <input type="text" name="host_url" value="<?= $config['host_url'] ?>" style="width:325px" />
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_MAIN_HOST_BASKSTAGE') ?>:</td>
                    <td>
                        <input type="text" name="host_url_backstage" value="<?= $config['host_url_backstage'] ?>" style="width:325px" />
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_MAIN_HOST_ANNOUNCEMENT') ?>:</td>
                    <td>
                        <input type="text" name="host_url_announcement" value="<?= $config['host_url_announcement'] ?>" style="width:325px" />
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_CURRENT_AREAID') ?>:<span style="display:block;color:#999;"></span></td>
                    <td>
                        <input type="text" name="area_id" value="<?= $config['area_id'] ?>" />
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_CURRENT_AREA_NAME') ?>:</td>
                    <td>
                        <input type="text" name="area_name" value="<?= $config['area_name'] ?>" />
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_SOCKET_PORT') ?>:</td>
                    <td>
                        <input type="text" name="socket_port" value="<?= $config['socket_port'] ?>" />
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_TIMEZONE') ?>:</td>
                    <td>
                        <?= $timezonelist; ?>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_LANGUAGE_LIB') ?>:</td>
                    <td>
                        <?php foreach ($applist as $m => $n) { ?>
                            <?= $n ?> : <input type="text" name="languages[<?= $m ?>]" style="width:60px" value="<?= isset($config['languages'][$m]) ? $config['languages'][$m] : '' ?>" />
                        <?php } ?>
                    </td>
                </tr>
                
                <tr>
                    <td><?= translate('GENERAL_CONFIG_CURRENTLOGO') ?>:</td>
                    <td>
                        <input type="text" name="currentLogo" value="<?= $config['currentLogo'] ?>" />
                    </td>
                </tr>
                
                <tr>
                    <td><?= translate('GENERAL_CONFIG_APC_CACHE') ?>:</td>
                    <td>
                        <input type="radio" name="apc[state]" value="true" <?= checkchecked(true, $config['apc']['state']) ?> /> <?= translate('OPEN') ?>
                        <input type="radio" name="apc[state]" value="false" <?= checkchecked(false, $config['apc']['state']) ?> /> <?= translate('CLOSE') ?>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_ERROR_LOG') ?>:</td>
                    <td>
                        <input type="radio" name="error_log" value="true" id="error_log_true" <?= checkchecked(true, $config['error_log']) ?> /> <label for="error_log_true"><?= translate('OPEN') ?></label>
                        <input type="radio" name="error_log" value="false" id="error_log_false" <?= checkchecked(false, $config['error_log']) ?> /> <label for="error_log_false"><?= translate('CLOSE') ?></label>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_FRAME_DEBUG_LOG') ?>:</td>
                    <td>
                        <input type="radio" name="debug_log" value="true" id="debug_log_true" <?= checkchecked(true, $config['debug_log']) ?> disabled/> <label for="debug_log_true"><?= translate('OPEN') ?></label>
                        <input type="radio" name="debug_log" value="false" id="debug_log_false" <?= checkchecked(false, $config['debug_log']) ?> disabled/> <label for="debug_log_false"><?= translate('CLOSE') ?></label>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_DATA_TRANS') ?>:</td>
                    <td>
                        <input type="radio" name="open_magic_quotes_gpc" value="true" id="open_magic_quotes_gpc_true" <?= checkchecked(true, $config['open_magic_quotes_gpc']) ?> disabled /> <label for="open_magic_quotes_gpc_true"><?= translate('OPEN') ?></label>
                        <input type="radio" name="open_magic_quotes_gpc" value="false" id="open_magic_quotes_gpc_false" <?= checkchecked(false, $config['open_magic_quotes_gpc']) ?> disabled /> <label for="open_magic_quotes_gpc_false"><?= translate('CLOSE') ?></label>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_URL_REWRITE') ?>:</td>
                    <td>
                        <input type="radio" name="url_rewrite" value="true" id="url_rewrite_true" <?= checkchecked(true, $config['url_rewrite']) ?> disabled /> <label for="url_rewrite_true"><?= translate('OPEN') ?></label>
                        <input type="radio" name="url_rewrite" value="false" id="url_rewrite_false" <?= checkchecked(false, $config['url_rewrite']) ?> disabled /> <label for="url_rewrite_false"><?= translate('CLOSE') ?></label>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_DATA_CODE_LOG') ?>:<span style="display:block;color:#999;"><?= translate('GENERAL_CONFIG_DATA_CODE_LOG_NOTE') ?></span></td>
                    <td>
                        <input type="text" name="code_log" value="<?= $config['code_log'] ?>" style="width:325px" /><a href="javascript:;" class="help" module="codeversion"><?= translate('README') ?></a>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_PRIVILEGE_ACCOUNT') ?>:<span style="display:block;color:#999;">  <?= translate('GENERAL_CONFIG_PRIVILEGE_ACCOUNT_NOTE', site_url('account/account')) ?></span></td>
                    <td>
                        <textarea name="white_list" cols="50" rows="5"><?= $config['white_list'] ?></textarea>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_FORBID_ROLE_NAME') ?>:<span style="display:block;color:#999;">  <?= translate('GENERAL_CONFIG_FORBID_ROLE_NOTE') ?></span></td>
                    <td>
                        <textarea name="forbidden_nickname" cols="50" rows="5"><?= str_replace("|", "\r\n", $config['forbidden_nickname']) ?></textarea>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_FORBID_DEVICE') ?>:<span style="display:block;color:#999;"><?= translate('GENERAL_CONFIG_FORBID_DEVICE_NOTE', site_url('account/account')) ?>  </span></td>
                    <td>
                        <textarea name="forbidden_deviceid" cols="50" rows="5"><?= str_replace("|", "\r\n", $config['forbidden_deviceid']) ?></textarea>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_URL_REG_FIND') ?>:<span style="display:block;color:#999;"><?= translate('GENERAL_CONFIG_URL_REG_FIND_NOTE') ?> </span></td>
                    <td>
                        <textarea name="url_search" cols="50" rows="1"><?= implode("\r\n", $config['url_search']) ?></textarea>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CONFIG_URL_REG_REP') ?>:<span style="display:block;color:#999;"><?= translate('GENERAL_CONFIG_URL_REG_REP_NOTE') ?></span></td>
                    <td>
                        <textarea name="url_replace" cols="50" rows="1"><?= implode("\r\n", $config['url_replace']) ?></textarea>
                    </td>
                </tr>
                <tr class="hide">
                    <td><?= translate('GENERAL_CONFIG_DEUBG_CTR_ACTS') ?>:</td>
                    <td>
                        <input type="text" name="root_controller" value="<?= $config['root_controller'] ?>" style="width:100px;" />
                        <input type="text" name="root_action" value="<?= $config['root_action'] ?>" style="width:100px;" />
                    </td>
                </tr>
                <tr class="hide">
                    <td><?= translate('GENERAL_CONFIG_DEFAULT_CTR_ACTS') ?>:</td>
                    <td>
                        <input type="text" name="default_controller" value="<?= $config['default_controller'] ?>" style="width:100px;" />
                        <input type="text" name="default_action" value="<?= $config['default_action'] ?>" style="width:100px;" />
                    </td>
                </tr>
                <tr>
                    <td><?= translate('C_ALLOW_VERSION') ?>:<span style="display:block;color:#999;">  <?= translate('GENERAL_CONFIG_ALLOW_VERSION_NOTE') ?></span></td>
                    <td>
                        <textarea name="allow_version" cols="50" rows="5"><?= implode("\r\n", $config['allow_version']) ?></textarea><a href="javascript:;" class="help" module="version"><?= translate('README') ?></a>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('C_DENY_VERSION') ?>:<span style="display:block;color:#999;">  <?= translate('GENERAL_CONFIG_FORBID_VERSION_NOTE', site_url('general/version')) ?></span></td>
                    <td>
                        <textarea name="deny_version" cols="50" rows="5"><?= implode("\r\n", $config['deny_version']) ?></textarea><a href="javascript:;" class="help" module="version"><?= translate('README') ?></a>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('VERSION') ?>:</td>
                    <td style="line-height:25px;">
                        <input type="text" name="version" value="<?= $config['version'] ?>" style="width:100px;" />
                    </td>
                </tr>
                <tr><td></td>
                    <td>
                        <input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/> <input type="reset" value="<?= translate('RESET') ?>" id="reset"/>
                    </td>
                </tr>
                <tr align="left" id="ip_whitelist">
                    <th class="t"><?= translate('GENERAL_CONFIG_ALLOW_IP') ?></th>
                    <th></th>
                </tr>
                <?php foreach ($applist as $m => $n) { ?>
                    <?php if (in_array($m, array('application', 'api'))) continue; ?>
                    <tr>
                        <td><?= $n ?> :<span style="display:block;color:#999;">  <?= translate('GENERAL_CONFIG_ALLOW_IP_NOTE') ?></span></td>
                        <td>
                            <textarea name="ip_whitelist[<?= $m ?>]" cols="50" rows="5"><?= str_replace("|", "\r\n", $config['ip_whitelist'][$m][$m]) ?></textarea>
                        </td>
                    </tr>        
                <?php } ?>
                <tr><td></td>
                    <td>
                        <input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/> <input type="reset" value="<?= translate('RESET') ?>" id="reset"/>
                    </td>
                </tr>
                <tr align="left" id="currency">
                    <th class="t"><?= translate('CURRENCY') ?><span style="display:block;color:#999;"><?= translate('GENERAL_CONFIG_REVENUE_CURRENCY') ?></span></th>
                    <th class="currency"><ul><li><?= translate('GENERAL_CONFIG_CURRENCY_ID') ?></li><li><?= translate('GENERAL_CONFIG_CURRENCY_NAME') ?></li><li><?= translate('GENERAL_CONFIG_CURRENCY_RATE') ?></li></ul></th>
                </tr>
                <?php
                $i = 0;
                foreach ($config['currency_list'] as $m => $n) {
                    $i++;
                    ?>
                    <tr class="currency">
                        <td><input type="radio" name="currency_list[revenue]" value="<?= $i ?>" <?= checkchecked($m, $config['currency_revenue']) ?> /></td>
                        <td>
                            <ul rel="<?= $i ?>">
                                <li><input type="text" name="currency_list[<?= $i ?>][id]" placeholder='<?= translate('GENERAL_CONFIG_CURRENCY_ID') ?>' value="<?= $m ?>" /></li>
                                <li><input type="text" name="currency_list[<?= $i ?>][name]" placeholder='<?= translate('GENERAL_CONFIG_CURRENCY_NAME') ?>' value="<?= $n['name'] ?>" /></li>
                                <li><input type="text" name="currency_list[<?= $i ?>][rate]" placeholder='<?= translate('GENERAL_CONFIG_CURRENCY_RATE') ?>' value="<?= $n['rate'] ?>" /><a href="http://qq.ip138.com/hl.asp?from=<?= $m ?>&to=CNY&q=100" title="汇率查询" class="dialog" follow="this" width="700"><img src="images/searchnow.png" alt="" /></a></li>
                            </ul>
                        </td>
                    </tr>
                <?php } ?>
                <tr>
                    <td></td>
                    <td><a href="javascript:;" id="appendcurrency"><?= translate('APPEND') ?></a></td>
                </tr>
                <tr><td></td>
                    <td>
                        <input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/> <input type="reset" value="<?= translate('RESET') ?>" id="reset"/>
                    </td>
                </tr>
            </table>
        </form>
        <script type="text/javascript">
            $(function() {
                var text = '';
                $("table.tableedit").children().children("[id]").each(function(i) {
                    text += '<a href="javascript:;" sid="' + $(this).attr("id") + '">' + $(".t", this).text() + '</a>';
                });
                $("#base_link").prepend(text);
                $("#base_link a").live("click", function() {
                    if ($(this).attr("sid")) {
                        $('html,body').animate({scrollTop: $('#' + $(this).attr("sid")).offset().top}, 500);
                    }
                });

                $("#appendcurrency").live("click", function() {
                    var p = $(this).parent().parent().prev();
                    var i = parseInt(p.find("ul").attr("rel")) + 1;
                    var n = $("<tr class='currency'>" + p.html().replace(/currency_list\[\d+\]/g, 'currency_list[' + i + ']') + "</tr>").insertAfter(p);
                    n.find("ul").attr('rel', i);
                    n.find("input").val('');
                    n.find("td:first").html('');
                });

                $("#restore").click(function() {
                    if (confirm('<?= translate('GENERAL_CONFIG_CONFIRM') ?>')) {
                        location.href = '<?= site_url("general/config/restore") ?>';
                    }
                });
            });
        </script>
    </body>
</html>